const mysql = require('mysql');

//建立连接
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'demhem'
})

//执行连接
connection.connect();
let data = {
    name: 'root',
    age:'113',
    money: '110'
}

//操作数据库
connection.query('insert into student SET ?',data,(error,result) => {
    if(error){
        console.log('error ====>',error);
        console.log('insert 错误')
    }
    if(result.affectedRows == 1){
        console.log('insert 成功')
    }
    console.log('result',result);
})

//关闭数据库、
connection.end();